Public Class AssemblyNode
    Implements ICloneable

    Private htParentAssemblies As Hashtable
    Private htChildAssemblies As Hashtable
    Private AssemblyName As String
    Private TblWebReferences As DataTable
    Private _RootNameSpace As String
    Private nodeVisited As Boolean
    Private nodecolormark As NodeColorEnum

    Public Enum NodeColorEnum
        WHITE
        BLACK
        GRAY
    End Enum

    Sub New(ByVal strAssmemblyName As String)
        htParentAssemblies = New Hashtable
        htChildAssemblies = New Hashtable
        AssemblyName = strAssmemblyName
        nodecolormark = NodeColorEnum.WHITE
    End Sub

    Public Sub AddParent(ByVal objParentAssmNode As AssemblyNode)
        If Not htParentAssemblies.Contains(objParentAssmNode.GetAssemblyName) Then
            htParentAssemblies.Add(objParentAssmNode.GetAssemblyName, objParentAssmNode)
        End If
    End Sub

    Public Sub AddChild(ByVal objChildAssmNode As AssemblyNode)
        If Not htChildAssemblies.Contains(objChildAssmNode.GetAssemblyName) Then
            htChildAssemblies.Add(objChildAssmNode.GetAssemblyName, objChildAssmNode)
        End If
    End Sub

    Public Property Visited() As Boolean
        Get
            Return nodeVisited
        End Get
        Set(ByVal Value As Boolean)
            nodeVisited = Value
        End Set
    End Property

    Public Property NodeColor() As NodeColorEnum
        Get
            Return nodecolormark
        End Get
        Set(ByVal Value As NodeColorEnum)
            nodecolormark = Value
        End Set
    End Property

    Public Property RootNameSpace() As String
        Get
            Return Me._RootNameSpace
        End Get
        Set(ByVal Value As String)
            _RootNameSpace = Value
        End Set
    End Property

    Public Property WebReferences() As DataTable
        Get
            Return Me.TblWebReferences
        End Get
        Set(ByVal Value As DataTable)
            TblWebReferences = Value
        End Set
    End Property

    Public ReadOnly Property GetParentAssemblies() As Hashtable
        Get
            Return htParentAssemblies
        End Get
    End Property

    Public ReadOnly Property GetChildAssemblies() As Hashtable
        Get
            Return htChildAssemblies
        End Get
    End Property

    Public Function HasAChild(ByVal ChildAssmbName As String) As Boolean
        If GetChildAssemblies.Contains(ChildAssmbName) Then
            Return True
        Else
            Return False
        End If
    End Function

    Public Function HasChildren() As Boolean
        If GetChildAssemblies.Count > 0 Then
            Return True
        Else
            Return False
        End If
    End Function

    Public ReadOnly Property GetAssemblyName() As String
        Get
            Return AssemblyName
        End Get
    End Property

    Private Shared Sub SortHashTable(ByVal myht As Hashtable)
        Dim myal As New ArrayList
        Dim endict As IDictionaryEnumerator
        Dim en As IEnumerator
        Dim arrIndx As Integer = 0

        endict = myht.GetEnumerator
        While endict.MoveNext
            myal.Add(CType(endict.Value, AssemblyNode))
        End While

        myal.Sort(New AssemblyNameComparer)
        myht.Clear()

        en = myal.GetEnumerator
        While en.MoveNext
            myht.Add(CType(en.Current, AssemblyNode).GetAssemblyName, CType(en.Current, AssemblyNode))
        End While
    End Sub

    Private Class AssemblyNameComparer
        Implements IComparer

        Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compare
            Dim objAssmb1 As AssemblyNode = DirectCast(x, AssemblyNode)
            Dim objAssmb2 As AssemblyNode = DirectCast(y, AssemblyNode)
            Return String.Compare(objAssmb1.GetAssemblyName, objAssmb2.GetAssemblyName)
        End Function

    End Class

    Public Function Clone() As Object Implements System.ICloneable.Clone
        Return MyClone()
    End Function

    Private Function MyClone() As AssemblyNode
        Dim x As AssemblyNode
        x = DirectCast(Me.MemberwiseClone, AssemblyNode)
        Return x
    End Function

End Class

